home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / WindowMaker / WINGs / dragdestination.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-03-27  |  2.4 KB  |  119 lines

  1.  
  2.  
  3. #include <X11/Xatom.h>
  4.  
  5. #include "WINGsP.h"
  6.  
  7.  
  8. /* dropping */
  9.  
  10. typedef struct W_DNDTargetInfo {
  11.     /* data types accepted for drops */
  12.     Atom *dropTypes;
  13.     int dropTypeCount;
  14.  
  15.  
  16. } DNDTargetInfo;
  17.  
  18.  
  19. static Atom XDNDversion = XDND_VERSION;
  20.  
  21.  
  22. static void
  23. realizedObserver(void *self, WMNotification *notif)
  24. {
  25.     WMView *view = (WMView*)WMGetNotificationObject(notif);
  26.         
  27.     XChangeProperty(W_VIEW_SCREEN(view)->display, W_VIEW_DRAWABLE(view), 
  28.             W_VIEW_SCREEN(view)->xdndAwareAtom,
  29.             XA_ATOM, 32, PropModeReplace,
  30.             (unsigned char*)&XDNDversion, 1);
  31.  
  32.     WMRemoveNotificationObserver(self);
  33. }
  34.  
  35.  
  36. void
  37. W_SetXdndAwareProperty(WMScreen *scr, WMView *view, Atom *types, int typeCount)
  38. {
  39.     Display *dpy = scr->display;
  40.  
  41.     view = W_TopLevelOfView(view);
  42.     
  43.     if (!view->flags.xdndHintSet) {    
  44.     view->flags.xdndHintSet = 1;
  45.     
  46.     if (view->flags.realized) {
  47.         XChangeProperty(dpy, W_VIEW_DRAWABLE(view), scr->xdndAwareAtom,
  48.                 XA_ATOM, 32, PropModeReplace,
  49.                 (unsigned char*)&XDNDversion, 1);
  50.     } else {
  51.         WMAddNotificationObserver(realizedObserver, view, 
  52.                       WMViewRealizedNotification, 
  53.                       /* just use as an id */
  54.                       view->dragDestinationProcs);
  55.     }
  56.     }
  57. }
  58.  
  59.  
  60.  
  61.  
  62. WMData*
  63. WMGetDroppedData(WMView *view, WMDraggingInfo *info)
  64. {
  65.     return NULL;
  66. }
  67.  
  68.  
  69. void
  70. WMRegisterViewForDraggedTypes(WMView *view, char *acceptedTypes[])
  71. {
  72.     Atom *types;
  73.     int typeCount;
  74.     int i;
  75.     
  76.     typeCount = 0;
  77.     while (acceptedTypes[typeCount++]);
  78.     
  79.     types = wmalloc(sizeof(Atom)*(typeCount+1));
  80.  
  81.     for (i = 0; i < typeCount; i++) {
  82.     types[i] = XInternAtom(W_VIEW_SCREEN(view)->display, 
  83.                    acceptedTypes[i], False);
  84.     }
  85.     types[i] = 0;
  86.  
  87.     view->droppableTypes = types;
  88.  
  89.     W_SetXdndAwareProperty(W_VIEW_SCREEN(view), view, types, typeCount);
  90. }
  91.  
  92.  
  93. void
  94. WMUnregisterViewDraggedTypes(WMView *view)
  95. {
  96.     if (view->droppableTypes != NULL)
  97.     free(view->droppableTypes);
  98.     view->droppableTypes = NULL;
  99. }
  100.  
  101. /***********************************************************************/
  102.  
  103. void
  104. WMSetViewDragDestinationProcs(WMView *view, WMDragDestinationProcs *procs)
  105. {
  106.     if (view->dragDestinationProcs == NULL) {
  107.     free(view->dragDestinationProcs);
  108.     view->dragDestinationProcs = wmalloc(sizeof(WMDragDestinationProcs));
  109.     }
  110.     *view->dragDestinationProcs = *procs;
  111.     
  112.     /*XXX fill in non-implemented stuffs */
  113. }
  114.  
  115.  
  116.  
  117.  
  118.  
  119.